home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_13_03
/
pjp
/
sstream
< prev
next >
Wrap
Text File
|
1995-02-01
|
2KB
|
58 lines
------------- Listing 1: The header <<sstream>> ------------------
// sstream standard header
#ifndef _SSTREAM_
#define _SSTREAM_
#include <<string>>
#include <<strstream>>
// class stringbuf
class stringbuf : public strstreambuf {
public:
stringbuf(ios::openmode _W = ios::in | ios::out)
: strstreambuf(0, 0, 0, _Mode(_W)) {}
stringbuf(const string& _S,
ios::openmode _W = ios::in | ios::out)
: strstreambuf((char *)_S.c_str(), _S.length(), 0,
_Mode(_W)) {}
virtual ~stringbuf();
string str() const;
void str(const string& _S);
protected:
_Strstate _Mode(ios::openmode);
};
// class istrstream
class istringstream : public istream {
public:
istringstream(openmode _W = in)
: istream(&_Sb), _Sb(_W) {}
istringstream(const string& _S, openmode _W = in)
: istream(&_Sb), _Sb(_S, _W) {}
virtual ~istringstream();
stringbuf *rdbuf() const
{return ((stringbuf *)&_Sb); }
string str() const
{return (_Sb.str()); }
void str(const string& _S)
{_Sb.str(_S); }
private:
stringbuf _Sb;
};
// class ostrstream
class ostringstream : public ostream {
public:
ostringstream(openmode _W = out)
: ostream(&_Sb), _Sb(_W) {}
ostringstream(const string& _S, openmode _W = out)
: ostream(&_Sb), _Sb(_S, _W) {}
virtual ~ostringstream();
stringbuf *rdbuf() const
{return ((stringbuf *)&_Sb); }
string str() const
{return (_Sb.str()); }
void str(const string& _S)
{_Sb.str(_S); }
private:
stringbuf _Sb;
};
#endif /* _SSTREAM_ */